package servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 04-thymeleaf入门
 */
@WebServlet("/demo01")
public class Demo01Servlet extends ViewBaseServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String errorMsg = "用户名已经存在!";
        req.setAttribute("errorMsg", errorMsg);
        //转发到demo01.html
        processTemplate("demo01", req, resp);
        //req.getRequestDispatcher("/pages/demo01.html").forward(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
